import { createRouter, createWebHistory } from 'vue-router'
import ACCESS_ENUM from '@/access/accessEnum'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('@/views/HomeView.vue')
    },
    {
			path: '/user/login',
			name: '用户登录',
			component: () => import('@/views/user/UserLoginView.vue'),
		},
		{
			path: '/user/register',
			name: '用户注册',
			component: () => import('@/views/user/UserRegisterView.vue'),
		},
		{
			path: '/user/profile',
			name: '个人主页',
			component: () => import('@/views/user/UserProfileView.vue'),
			meta: {
				access: ACCESS_ENUM.USER, // 需要登录
			}
		},
		{
			path: '/user/vip',
			name: 'VIP会员',
			component: () => import('@/views/user/UserVipView.vue'),
			meta: {
				access: ACCESS_ENUM.USER, // 需要登录
			}
		},
		// App 应用相关路由
		{
			path: '/app/:id',
			name: '应用生成对话',
			component: () => import('@/views/app/AppChatView.vue'),
		},
		{
			path: '/app/edit/:id',
			name: '应用信息修改',
			component: () => import('@/views/app/AppEditView.vue'),
			meta: {
				access: ACCESS_ENUM.USER, // 需要登录
			}
		},
    {
			path: '/admin/userManage',
			name: '用户管理',
			component: () => import('@/views/admin/UserManageView.vue'),
      meta: {
        access: ACCESS_ENUM.ADMIN, // 需要管理员权限
      }
		},
		{
			path: '/admin/appManage',
			name: '应用管理',
			component: () => import('@/views/admin/AppManageView.vue'),
			meta: {
				access: ACCESS_ENUM.ADMIN, // 需要管理员权限
			}
		},
		{
			path: '/admin/chatHistoryManage',
			name: '对话管理',
			component: () => import('@/views/admin/ChatHistoryManageView.vue'),
			meta: {
				access: ACCESS_ENUM.ADMIN, // 需要管理员权限
			}
		},
    {
			path: '/admin/vipManage',
			name: 'VIP管理',
			component: () => import('@/views/admin/VipManageView.vue'),
      meta: {
        access: ACCESS_ENUM.ADMIN, // 需要管理员权限
      }
		},
    {
			path: '/noAuth',
			name: '无权限',
			component: () => import('@/views/error/NoAuthView.vue'),
		},
		{
			path: '/:pathMatch(.*)*',
			name: '404',
			component: () => import('@/views/error/NotFoundView.vue'),
		},
  ],
})

export default router
